package tester.input;

import messages.MessageType;
import messages.MessageUtils;

/**
 * This message is a tester specific message denoting that the tester must wait for a given
 * amount of time before proceeding to the next message.
 * @author Caleb Chan
 *
 */
public class CreateDelayMessage extends TesterMessage {

	private int sleepLength;
	
	/**
	 * CreateDelayMessage constructor 
	 * @param data The data representation of a CreateDelayMessage
	 */
	public CreateDelayMessage(byte [] data){
		sleepLength = MessageUtils.parseInt(data, 1);
	}
	
	/**
	 * CreateDelayMessage constructor
	 * @param sleepLength The length of the sleep
	 */
	public CreateDelayMessage(int sleepLength){
		this.sleepLength = sleepLength;
	}

	/**
	 * This message will return the length of the sleep
	 * @return
	 */
	public int getSleepLength() {
		return sleepLength;
	}

	@Override
	public MessageType getMessageType(){
		return null;
	}
	
	@Override
	public byte[] toByteArray(){
		byte[] out = new byte[5];
		out[0] = getTesterMessageType().getIdentifier();
		
		MessageUtils.insertInt(out, 1, sleepLength);
		return out;
	}
	
	/**
	 * This method will return the tester specific message type
	 */
	public TesterMessageType getTesterMessageType(){
		return TesterMessageType.CreateDelayMessage;
	}

}
